﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    Business businessModel = ViewBag.Business;
    ItemListBox<Product> productList = ViewBag.ProductList;
    ViewBag.Title = businessModel.Name;
    Layout = "~/Views/Shared/_Main.cshtml";
}
<!--#主菜单-->
<div class="container">
    <ul class="breadcrumb">
        <li><a href="#">首页</a> <span class="divider">/</span></li>
        <li><a href="/shop/FastFood">订餐商家列表</a> <span class="divider">/</span></li>
        <li class="active">@businessModel.Name</li>
    </ul>
    <!--//////////////////////////////////////////////////////////////////////////////////-->
    <div class="row">
        <div class="span9">
            @{
                string isWork = "正在营业";
                string url = "/shop/FastFoodDetail?d=";
                string[] startTimeArr = businessModel.DeliveryTime.Split('|');
                string[] endTimeArr = businessModel.DeliveryTimeEnd.Split('|');

                if (startTimeArr != null && startTimeArr.Length != 0)
                {
                    for (int timeIndex = 0; timeIndex < startTimeArr.Length; timeIndex++)
                    {
                        if (Convert.ToDateTime(DateTime.Now.ToShortDateString() + " " + startTimeArr[timeIndex]) < DateTime.Now &&
                            DateTime.Now < Convert.ToDateTime(DateTime.Now.ToShortDateString() + " " + endTimeArr[timeIndex]))
                        {
                            isWork = "正在营业";
                            url = "/shop/FastFoodDetail?d=";
                        }
                        else
                        {
                            isWork = "已打烊";
                            url = "#";
                        }
                    }
                }
                
                if(productList!=null&&productList.Data!=null&&productList.Data.Count!=0)
                {
                    string imgurlproduct = "";
                    int sellProductNumber = 0;
                    int id=0;
                    int key=0;
                    for (int i = 0; i < productList.Data.Count; i++)
			        {			
                        
                <div class="row-fluid">
                    @{
                        for (int j = 0; j < 3; j++)
			            {              
                            if(key==productList.Data.Count){
                                i = key;
                                break;
                            }

                            id = productList.Data[key].Id;
                            if (!string.IsNullOrEmpty(productList.Data[key].Images))
                            {
                                imgurlproduct = productList.Data[key].Images.Split(';')[0];
                            }else{
                                imgurlproduct = "";
                            }
                            sellProductNumber = new OrderDetail().Count(c => c.AreaCode == 10 && c.ProductId == id);
			
                            if(!url.Equals("#"))
                            {
                                url += id;
                            }
                        <div class="span4 mer-menu">
                            <!--cover:215x139-->
                            <a href="@url">
                                <img src="@imgurlproduct" style="min-height:139px; min-width:215px; height:139px; width:215px;" /></a>
                            <h4>
                                <a href="@url">@productList.Data[key].ProductName</a></h4>
                            <div>
                                <span class="label label-info">订购:&nbsp;@sellProductNumber</span> <span class="label label-important">
                                    评价:&nbsp;4.8</span>
                            </div>
                            <div class="text-right menu-pay-box">
                                <a href="@url" class=""><span class="icon-ok"></span>&nbsp;购买 </a>
                            </div>
                        </div>
                        
                            key++;
                        }
                    }
                </div>
                <br />
                <!--//////////////////////////////////////////////////////////////////////////////////-->
            <!--#菜品列表-->

                    }
                                <!--分页-->
            <div class="pagination text-right">
                <hr />
                <div class="text-left span3">
                    @Html.Raw(productList.PageItemSegment)
                </div>
                <!--#分页-->
            </div>
                }
                else
                {
                <div style="margin-left: 80px; margin-top: 80px">
                    <p style="vertical-align: middle">
                        <b style="font-size: 20px; color: Green">没有相关数据！</b></p>
                </div>
                }
            }
            </div>
            <div class="span3">
                <!--商家card-->
                <div class="title-line title-line-red">
                    <h4>
                        店家名片</h4>
                </div>
                <div class="row-fluid">
                    <div class="span12 merchant merchant-selected">
                        <!--cover:215x139-->
                        <a href="/shop/FastFoodBusiness?d=@businessModel.Id">
                            @{
                                int orderNumber = new Order().Count(c => c.AreaCode == 10 && c.BusinessID == businessModel.Id);
                                string imgurl = "";
                                if (!string.IsNullOrEmpty(@businessModel.Logo))
                                {
                                    imgurl = @businessModel.Logo.Split(';')[0];
                                }
                                else
                                {
                                    imgurl = "";
                                }
                                <img src="@imgurl" alt="@businessModel.Name" />
                            }
                        </a>
                        <h4>
                            <a href="/shop/FastFoodBusiness?d=@businessModel.Id">@businessModel.Name</a></h4>
                        <div>
                            <span>主营：</span> <a href="#">@businessModel.MainSell</a>
                        </div>
                       
                        <div>
                            <span>送餐时间：</span>@{

                                if (startTimeArr != null && startTimeArr.Length != 0)
                              {
                                  for (int i = 0; i < startTimeArr.Length; i++)
                                  {
                                      <span>@startTimeArr[i]~@endTimeArr[i]</span><br />
                                  }
                              }
                                }
                        </div>
                        <div>
                            <span>地址：</span>@businessModel.Address
                        </div>
                        <div>
                            <span class="label label-info">
                                订购:&nbsp;@orderNumber</span>
                            <span class="label label-important">评价:&nbsp;@businessModel.Levels</span>
                            <span class="label label-info">@isWork</span>
                        </div>
                    </div>
                </div>
                <!--#商家card-->
                <div>
                </div>
                <br />
            </div>
        </div>
    </div>
